from pydantic import BaseModel, Field, EmailStr


# 定义请求结构
class UserBase(BaseModel):
    username: str
    


class UserCreate(UserBase):
    password: str


class UserUpdate(BaseModel):
    username: str | None = None


# 定义响应结构
class UserOut(UserBase):
    id: int
    username: str = Field(..., description="用户名")  #  响应字段别名与文档描述serialization_alias = "username",
 
    model_config = {
        "from_attributes": True,  # 允许从模型属性中创建响应结构 v2 的写法（推荐）
        # 排除掉 password 字段
        # "exclude": {"hashed_password"},  # 排除掉 password 字段
    }
